package com.cskaoyan._02charstream._04in;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/18 11:50
 **/
/*
转换输入流
 */
public class Demo {
    public static void main(String[] args) throws IOException {
        // 创建输入流对象
        InputStreamReader in = new InputStreamReader(new FileInputStream("a.txt"));

        // read
        // read(): 读单个字符 返回值表示读取到的字符值 readData
        int readData = in.read();
        System.out.println(((char) readData));

        // read(char[] c): 读取数据填充数组 返回值代表读取到的字符的个数 readCount
        char[] chars = new char[1024];
        int readCount = in.read(chars);
        System.out.println(new String(chars,0,readCount));
        // read(char[] c,int off,int len)

        // close
        in.close();
    }
}
